From: Georges Basile Stavracas Neto Date: Tue, 9 Aug 2022 22:39:41 +0000 (-0300) Subject: appDisplay: Bring back drag overshoot region X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~56 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4dcae8ddd2637384b82fcbaa5ebd26c3dc2b77cd;p=gnome-shell.git appDisplay: Bring back drag overshoot region This is a region where, if hovered while dragging, immediately goes to the previous or next page. This behavior was lost during the transition to the new app grid layout manager. Bring back the drag overshoot region. Part-of: --- diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index 9ede9a690..92ed05b72 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -43,6 +43,7 @@ const PAGE_PREVIEW_ANIMATION_TIME = 150; const PAGE_INDICATOR_FADE_TIME = 200; const PAGE_PREVIEW_RATIO = 0.20; +const OVERSHOOT_THRESHOLD = 20; const OVERSHOOT_TIMEOUT = 300; const DELAYED_MOVE_TIMEOUT = 200; @@ -843,6 +844,23 @@ var BaseAppView = GObject.registerClass({ this._overshootTimeoutId = 0; } + _dragWithinOvershootRegion(dragEvent) { + const rtl = this.get_text_direction() === Clutter.TextDirection.RTL; + const {x, y, targetActor: indicator} = dragEvent; + const [indicatorX, indicatorY] = indicator.get_transformed_position(); + const [indicatorWidth, indicatorHeight] = indicator.get_transformed_size(); + + let overshootX = indicatorX; + if (indicator === this._nextPageIndicator || rtl) + overshootX += indicatorWidth - OVERSHOOT_THRESHOLD; + + const overshootBox = new Clutter.ActorBox(); + overshootBox.set_origin(overshootX, indicatorY); + overshootBox.set_size(OVERSHOOT_THRESHOLD, indicatorHeight); + + return overshootBox.contains(x, y); + } + _handleDragOvershoot(dragEvent) { // Already animating if (this._adjustment.get_transition('value') !== null) @@ -868,6 +886,13 @@ var BaseAppView = GObject.registerClass({ if (targetPage < 0 || targetPage >= this._grid.nPages) return; // don't go beyond first/last page + // If dragging over the drag overshoot threshold region, immediately + // switch pages + if (this._dragWithinOvershootRegion(dragEvent)) { + this._resetOvershoot(); + this.goToPage(targetPage); + } + this._overshootTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, OVERSHOOT_TIMEOUT, () => { this._resetOvershoot();